package com.sanery.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import com.sanery.entity.Opinoin;

public class ListDaoImpl {
	public List<Opinoin> getAllList() {
		List<Opinoin> list = new ArrayList<Opinoin>();
		try {
			Class.forName("com.mysql.jdbc.Driver");
			Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/opinionbook", "root", "123456");
			String sql = "select id,content,empid,agree from sugs";
			PreparedStatement pstmt = conn.prepareStatement(sql);
			ResultSet rs = pstmt.executeQuery();
			while (rs.next()) {
				Opinoin o = new Opinoin();
				o.setId(rs.getInt(1));
				o.setContent(rs.getString(2));
				o.setEmpid(rs.getInt(3));
				o.setAgree(rs.getInt(4));
				list.add(o);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return list;
	}
}
